home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / viewers / pcshow / df.h next >
C/C++ Source or Header  |  1991-07-01  |  8KB  |  218 lines

  1. /*------------------------------------------------------------------------------
  2.  * File:     df.h
  3.  * Purpose:    header file for HDF routines
  4.  * Invokes:    dfi.h
  5.  * Contents: 
  6.  *    Structure definitions: DFddh, DFdd, DFdesc, DFdle, DF, DFdi, DFdata
  7.  *    Procedure type definitions
  8.  *    Global variables
  9.  *    Tag definitions
  10.  *  Error return codes
  11.  *    Logical constants
  12.  * Remarks: This file is included with user programs
  13.  *            Since it includes stdio.h etc., do not include these after df.h
  14.  *----------------------------------------------------------------------------*/
  15.  
  16.  
  17. #ifndef DFTG_NULL                /* avoid re-inclusion */
  18.  
  19. /* include DF (internal) header information */
  20. #include "dfi.h"
  21.  
  22. /*--------------------------------------------------------------------------*/
  23. /*                        Type declarations                                     */
  24.  
  25. typedef struct DFddh {        /* format of data descriptor headers as in file */
  26.     int16
  27.         dds;                /* number of dds in header block */
  28.     int32    
  29.         next;                /* offset of next header block */
  30.     } DFddh;
  31.  
  32.         
  33. typedef struct DFdd {        /* format of data descriptors as in file */
  34.     uint16
  35.         tag,                /* data tag */
  36.         ref;                /* data reference number */
  37.     int32
  38.         offset,                /* offset of data element in file */
  39.         length;                /* number of bytes */
  40.     } DFdd;
  41.  
  42.  
  43.     /* descriptor structure is same as dd structure.  ###Note: may be changed */
  44. #define DFdesc    DFdd
  45.  
  46.  
  47.     /* DLE is the internal structure which stores data descriptor information */
  48.     /* It is a linked list of DDs */
  49. typedef struct DFdle {        /* Data List element */
  50.     struct DFdle
  51.         *next;                /* link to next dle */
  52.     DFddh
  53.         ddh;                /* To store headers */
  54.     DFdd
  55.         dd[1];                /* dummy size */
  56.     } DFdle;    
  57.  
  58.  
  59.     /* DF is the internal structure associated with each DF file */
  60.     /* It holds information associated with the file as a whole */
  61.     /* ### Note: there are hooks for having multiple DF files open at a time */
  62. typedef struct DF {
  63.     DFdle
  64.         *list,            /* Pointer to the DLE list */
  65.         *last_dle;        /* last_dle and last_dd are used in searches to indicate
  66.                             element returned by previous call to DFfind */
  67.     int
  68.         type,            /* 0= not in use, 1= normal, -1 = multiple */
  69.                         /* this is a hook for when multiple files are open */
  70.         access,            /* permitted access types: 0=none, 1=r, 2=w, 3=r/w */
  71.         changed,         /* True if anything in DDs modified since last write */
  72.         last_tag,        /* Last tag searched for by DFfind */
  73.         last_ref,        /* Last reference number searched for */
  74.         last_dd,        /* see last_dle */
  75.         defdds,            /* default numer of DD's in each block */
  76.         up_access;        /* access permissions to element being read/updated */
  77.                         /* Used by DFstart */
  78.     DFdd
  79.         *up_dd;            /* DD of element being read/updated, used by DFstart */
  80.               /* file handle is a file pointer or file descriptor */
  81.             /* depending on whether we use buffered or unbuffered i/o */
  82. #ifdef DF_BUFFIO
  83.     FILE *                /* file pointer */
  84. #else DF_BUFFIO
  85.     int                    /* file descriptor */
  86. #endif DF_BUFFIO
  87.         file;            /* File handle for real file */
  88. } DF;
  89.  
  90.  
  91. typedef struct DFdi {    /* data identifier: specifies data element uniquely */
  92.     uint16 tag;
  93.     uint16 ref;
  94. } DFdi;
  95.  
  96.  
  97.  
  98. typedef struct DFdata {    /* structure for returning status information */
  99.     int version;        /* version number of stat information */
  100. } DFdata;
  101.  
  102. /*--------------------------------------------------------------------------*/
  103. /*                            Procedure types                                 */
  104.  
  105. DF *DFopen();
  106. int32 DFgetelement();
  107. int32 DFread();
  108. int32 DFseek();
  109. int32 DFwrite();
  110.  
  111. /*--------------------------------------------------------------------------*/
  112. /*                            Global Variables                                 */
  113.  
  114. #ifndef DFMASTER
  115. extern
  116. #endif DFMASTER
  117. int
  118.     DFerror;            /* Error code for DF routines */
  119.  
  120. /*--------------------------------------------------------------------------*/
  121. /*                             Tag Definitions                                */
  122.  
  123. #define DFREF_WILDCARD 0    /* wildcard ref for searches */
  124.  
  125. #define DFTG_WILDCARD 0    /* wildcard tag for searches */
  126. #define    DFTG_NULL    1        /* empty DD */
  127.  
  128. #define DFTG_FID    100        /* File identifier */
  129. #define    DFTG_FD    101        /* File description */
  130. #define    DFTG_TID    102        /* Tag identifier */
  131. #define    DFTG_TD    103        /* Tag descriptor */
  132. #define DFTG_DIL    104        /* data identifier label */
  133. #define DFTG_DIA    105        /* data identifier annotation */
  134. #define DFTG_NT    106        /* number type */
  135. #define DFTG_MT    107        /* machine type */
  136.  
  137. #define DFTG_ID8    200        /* 8-bit Image dimension */
  138. #define DFTG_IP8    201        /* 8-bit Image palette */
  139. #define DFTG_RI8    202        /* Raster-8 image */
  140. #define DFTG_CI8    203        /* RLE compressed 8-bit image */
  141. #define DFTG_II8    204        /* IMCOMP compressed 8-bit image */
  142.  
  143. #define DFTG_ID    300        /* Image DimRec */
  144. #define DFTG_LUT    301        /* Image Palette */
  145. #define    DFTG_RI    302        /* Raster Image */
  146. #define    DFTG_CI    303        /* Compressed Image */
  147.  
  148. #define DFTG_RIG    306        /* Raster Image Group */
  149. #define DFTG_LD    307        /* Palette DimRec */
  150. #define    DFTG_MD    308        /* Matte DimRec */
  151. #define DFTG_MA    309        /* Matte Data */
  152. #define DFTG_CCN    310        /* color correction */
  153. #define DFTG_CFM    311        /* color format */
  154. #define DFTG_AR    312        /* aspect ratio */
  155.     
  156. #define    DFTG_DRAW    400        /* Draw these images in sequence */
  157. #define    DFTG_RUN    401        /* run this as a program/script */
  158.  
  159. #define DFTG_XYP    500        /* x-y position */
  160. #define DFTG_MTO    501        /* machine-type override */
  161.  
  162. #define DFTG_T14    602        /* TEK 4014 data */
  163. #define DFTG_T105    603        /* TEK 4105 data */
  164.  
  165.     /* compression schemes */
  166. #define DFTG_RLE    11        /* run length encoding */
  167. #define DFTG_IMCOMP 12        /* IMCOMP compression */
  168.  
  169. /*--------------------------------------------------------------------------*/
  170. /*                            Error Return Codes                                 */
  171.  
  172. #define    DFE_NOERROR        0    /* No error */
  173. #define    DFE_FNF            -1    /* File not found error */
  174. #define    DFE_DENIED        -2    /* Access to file denied */
  175. #define    DFE_ALROPEN        -3    /* File already open */
  176. #define    DFE_TOOMANY        -4    /* Too Many DF's or files open */
  177. #define DFE_BNAME        -5    /* Bad file name on open */
  178. #define    DFE_BACC        -6    /* Bad file access mode */
  179. #define DFE_BOPEN        -7    /* Other open error */
  180. #define DFE_NOTOPEN        -8    /* File can't be closed 'cause it isn't open */
  181. #define DFE_CANTCLOSE    -9    /* fclose wouldn't work! */
  182. #define DFE_DFNULL        -10    /* DF is a null pointer */
  183. #define DFE_ILLTYPE        -11    /* DF has an illegal type: internal error */
  184. #define DFE_UNSUPPORTED    -12    /* Feature not currently supported */
  185. #define DFE_BDDLIST    -13    /* The DD list is non-existent: internal error */
  186. #define DFE_NOTDFFILE    -14    /* This is not a DF file and it is not 0 length */
  187. #define DFE_SEEDTWICE    -15    /* The DD list already seeded: internal error */
  188. #define    DFE_NOSPACE        -16    /* Malloc failed */
  189. #define    DFE_NOSUCHTAG    -17    /* There is no such tag in the file: search failed*/
  190. #define DFE_READERROR    -18    /* There was a read error */
  191. #define DFE_WRITEERROR    -19    /* There was a write error */
  192. #define DFE_SEEKERROR    -20    /* There was a seek error */
  193. #define DFE_NOFREEDD    -21    /* There are no free DD's left: internal error */
  194. #define DFE_BTAG        -22    /* illegal WILDCARD tag */
  195. #define DFE_BREF        -23    /* illegal WILDCARD reference # */
  196. #define DFE_RDONLY        -24    /* The DF is read only */
  197. #define DFE_BCALL        -25    /* Calls in wrong order */
  198. #define DFE_BPTR        -26 /* NULL ptr argument */
  199. #define DFE_BLEN        -27    /* negative len specified */
  200. #define DFE_BSEEK        -28    /* Attempt to seek past end of element */
  201. #define DFE_NOMATCH        -29    /* No (more) DDs which match specified tag/ref */
  202. #define DFE_NOTINSET    -30    /* Warning: Set contained unknown tag: ignored */
  203. #define DFE_BDIM        -31    /* negative or zero dimensions specified */
  204. #define DFE_BOFFSET    -32    /* Illegal offset specified */
  205. #define DFE_BSCHEME    -33    /* Unknown compression scheme specified */
  206. #define DFE_NODIM        -34    /* No dimension record associated with image */
  207. #define DFE_NOTENOUGH    -35    /* space provided insufficient for size of data */
  208.  
  209. /*--------------------------------------------------------------------------*/
  210. /*                            Logical Constants                                 */
  211.  
  212. #define DFACC_READ        1    /* Read Access */
  213. #define DFACC_WRITE        2    /* Write Access */
  214. #define DFACC_CREATE    4    /* force file to be created */
  215. #define DFACC_ALL        7    /* the logical and of all the above values */
  216.  
  217. #endif DFTG_NULL
  218.